package com.undsf.despot.modles;

/**
 * Created by Arathi on 2016/10/6.
 */
@Deprecated
public class Identify {
    public int id;
    public String code;

    public Identify(String code) {
        id = 0;
        for (int i=0; i<4; i++) {
            char c = code.charAt(i);
            id *= 0x100;
            id += c;
        }
        this.code = code;
    }

    public Identify(int id) {
        this.id = id;
        StringBuffer sb = new StringBuffer();
        for (int i=0; i<4; i++) {
            char c = (char)(id % 0x100);
            sb.insert(0, c);
            id /= 0x100;
        }
        code = sb.toString();
    }

    public boolean equals(Identify other) {
        return (id == other.id);
    }

    @Override
    public String toString() {
        return "'" + code + "'" + "(" + String.format("%h", id) + ")";
    }
}
